package hash;

import java.util.*;
import java.io.*;
import hash.HashTable;
import hash.HashMapObject;

public class Hash {         
    
    public static void main(String[] args) {
        
        HashTable HT = new HashTable();
        
        
        try {
                
            BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("1.txt"),("Windows-1251")));    
            BufferedWriter outfile = new BufferedWriter(new FileWriter("fileout.txt"));
              
               String str;                
                while ((str = in.readLine()) != null) {//разбиваем строку на слова, фильтруя знаки препинания
                        for (int i = 0; i < str.length(); i++) {
                            char c = str.charAt(i);
                            if ( c =='.' || c ==',' || c =='!' || c =='?' || c =='…' || c ==':' || c ==';' || c =='-' || c =='"' )
                                str = str.substring(0, i) + str.substring(i+1);                            
                            }                         
                        Scanner sc = new Scanner(str);
                        while (sc.hasNext()){ 
                                        String s = sc.next().toLowerCase();                                 
                                        HT.set_elem ( s );                                                         
                                        }        
                        }
                in.close(); 
        for (int i = 0;  i < HT.List.length; i++) {
                ListIterator<HashMapObject> j=HT.List[i].listIterator();
                while (j.hasNext()) {
                    HashMapObject t=j.next();
                    System.out.println(t.N+" | "+t.S);
                    }    
                    }       
                outfile.close();             
        } 
        catch (IOException e) {System.out.print("true exception");
            }   
       for (int i = 0;  i < HT.List.length; i++) {
                ListIterator<HashMapObject> j=HT.List[i].listIterator();
                while (j.hasNext()) {
                    HashMapObject t=j.next();
                    System.out.println(t.N+" | "+t.S);
                    }    
                    }       
            }
}
      

